<?php
$directory = "data/";

if (isset($_POST['filename'])&&!empty($_POST['filename'])&&
    isset($_POST['content'])&&!empty($_POST['content']))
{
  $filename = $_POST['filename'];
  $content = $_POST['content'];
  $fp = fopen($filename, 'w');
  fwrite($fp, $content);
  fclose($fp);
  echo $content;
}
else
{
  echo "error";
}
?>